package org.akomantoso.core.data;

import java.io.IOException;

import org.akomantoso.core.io.Externalizable;
import org.akomantoso.core.io.Input;
import org.akomantoso.core.io.Output;
import org.akomantoso.core.visitor.AKVisitor;

/**
 * The type judgementStructure specifies the overall content model of the document types that describe judgements.
 * 
 * <pre>
 * 	<xsd:complexType name="judgementStructure">
 * 		<xsd:sequence>
 * 			<xsd:element ref="meta"/>
 * 			<xsd:element ref="coverPage" minOccurs="0" maxOccurs="1"/>
 * 			<xsd:element ref="header"/>
 * 			<xsd:element ref="judgementBody"/>
 * 			<xsd:element ref="conclusions" minOccurs="0" maxOccurs="1"/>
 * 			<xsd:element ref="attachments" minOccurs="0" maxOccurs="1"/>
 * 		</xsd:sequence>
 * 		<xsd:attribute name="contains" type="versionType" default="originalVersion"/>
 *	</xsd:complexType>
 * </pre>
 * 
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 * 
 * @since http://www.akomantoso.org/1.0
 */
// TODO
public abstract class JudgementStructure implements Externalizable{

	// Mandatory
	private final Meta _meta = new Meta();
	
	// Optional
	private CoverPage _coverPage;
	
	// Mandatory
	private final Header _header = new Header();
	
	// Mandatory
	private final JudgementBody _body = new JudgementBody();
	
	public Meta getMeta() {
		return _meta;
	}
	
	public CoverPage getCoverPage() {
		return _coverPage;
	}

	public void setCoverPage(CoverPage coverPage) {
		_coverPage = coverPage;
	}

	public Header getHeader() {
		return _header;
	}

	public JudgementBody getBody() {
		return _body;
	}

	/**
	 * @see org.akomantoso.core.io.Externalizable#writeExternal(org.akomantoso.core.io.Output)
	 */
	@Override
	public <T extends Output> void writeExternal(T out) throws IOException {
		_meta.writeExternal(out);
		_header.writeExternal(out);
		_body.writeExternal(out);
	}
	
	/**
	 * @see org.akomantoso.core.io.Externalizable#readExternal(org.akomantoso.core.io.Input)
	 */
	@Override
	public <T extends Input> void readExternal(T in) throws IOException {
		in.readNextStartElement();
		_meta.readExternal(in);
		_header.readExternal(in);
		
		in.readNextStartElement();
		_body.readExternal(in);
	}
	

	protected final void internalAccept(AKVisitor visitor) {
		_meta.accept(visitor);
	}
	
}